package com.hzit.bj1804.dianweb.controller;







import com.github.pagehelper.PageInfo;
import com.hzit.bj1804.dian.entity.Orderinfo;
import com.hzit.bj1804.dian.entity.Productinfo;
import com.hzit.bj1804.dian.vo.CodeShuJu;
import com.hzit.bj1804.dian.vo.OrderdetailsOrderinfoProductinfo;
import com.hzit.bj1804.dian.vo.OrderinfoMemberpay;
import com.hzit.bj1804.dian.vo.PageRequest;
import com.hzit.bj1804.dianweb.service.OrderinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
//

@Controller
public class OrderListController {

    @Autowired
    private OrderinfoService orderinfoService;
    //显示所有信息，实现分类
    @RequestMapping("orderlist")
    @ResponseBody
    public Object oooo(int page,int limit){
        PageRequest pageRequest = new PageRequest();
        pageRequest.setLimit(limit);
        pageRequest.setPage(page);
        PageInfo<OrderdetailsOrderinfoProductinfo> all = orderinfoService.all(pageRequest);
        CodeShuJu ju = new CodeShuJu();
        //获取对象PageInfo对象中的集合对象
        ju.setData(all.getList());
        //数据总条数all.getTotal()
        ju.setCount(all.getTotal());
        return ju;
    }
    //根据id显示信息，实现分类
    @RequestMapping("orderList_order")
    @ResponseBody
    public Object aaa(int page,int limit ,@RequestParam("orderid") int orderid){
        PageRequest pageRequest = new PageRequest();
        pageRequest.setLimit(limit);
        pageRequest.setPage(page);
        System.out.println(orderid);
        System.out.println(pageRequest);
        PageInfo<OrderdetailsOrderinfoProductinfo> xi = orderinfoService.selectByIdXinXi(pageRequest, orderid);
        System.out.println(xi);
        CodeShuJu codeShuJu = new CodeShuJu();
        codeShuJu.setCount(xi.getTotal());
        codeShuJu.setData(xi.getList());
        return codeShuJu;
    }
    //修改订单状态
    @RequestMapping("updateStutess")
    @ResponseBody
    public Object update(Orderinfo orderinfo){
        int i = orderinfoService.updateStutes(orderinfo);
        return i;
    }
    //下单时间查询订单
    @RequestMapping("selectTime")
    @ResponseBody
    public Object selectTime(int page,int limit,@RequestParam("ordertime") String ordertime){
        PageRequest pageRequest = new PageRequest();
        pageRequest.setLimit(limit);
        pageRequest.setPage(page);
        System.out.println("AAAAAAAAAAAA");
        PageInfo<Orderinfo> orderinfoPageInfo = orderinfoService.selectTime(pageRequest, ordertime);
        CodeShuJu ju = new CodeShuJu();
        //获取对象PageInfo对象中的集合对象
        ju.setData(orderinfoPageInfo.getList());
        //数据总条数all.getTotal()
        ju.setCount(orderinfoPageInfo.getTotal());
        System.out.println(orderinfoPageInfo.getList());
        return ju;
    }
    //根据会员名称搜索订单
    @RequestMapping("selectName")
    @ResponseBody
    public Object selectName(@RequestParam("cardholdername") String cardholdername){
        List<OrderinfoMemberpay> orderinfoMemberpays = orderinfoService.selectName(cardholdername);
        CodeShuJu ju = new CodeShuJu();
        //获取对象PageInfo对象中的集合对象
        ju.setData(orderinfoMemberpays);
        return ju;
    }
    //根据id查询商品信息
    @RequestMapping("order_list_product")
    public Object aaa(@RequestParam("productid") int productid, ModelMap modelMap){
        Productinfo productinfo = orderinfoService.selectShangPing(productid);
        modelMap.put("productinfo",productinfo);
        return "netshop/order_list_product";}
    //根据id查询订单详细信息
    @RequestMapping("order_list_order")
    public Object zz(@RequestParam("orderid") int orderid,ModelMap modelMap){
//        System.out.println(orderid);
        modelMap.put("orderid",orderid);
        return "netshop/order_list_order";
    }


//    @RequestMapping("member_list")
//    public Object one(){
//        return "netshop/member_list";
//    }
//    @RequestMapping("member_report")
//    public Object two(){
//        return "netshop/member_report";
//    }
//    @RequestMapping("product_list")
//    public Object three(){
//        return "netshop/product_list";
//    }
//    @RequestMapping("itemadd")
//    public Object ten(){
//        return "netshop/itemadd";
//    }
//    @RequestMapping("edit_commodity")
//    public Object four(){
//        return "netshop/edit_commodity";
//    }
//    @RequestMapping("category_list")
//    public Object five(){
//        return "netshop/category_list";
//    }
//    @RequestMapping("order_list")
//    public Object six(){
//        return "netshop/order_list";
//    }
//    @RequestMapping("log")
//    public Object seven(){
//        return "netshop/log";
//    }
//    @RequestMapping("system_login")
//    public Object eight(){
//        return "netshop/system_login";
//    }
//    @RequestMapping("change_password")
//    public Object nine(){
//        return "netshop/change_password";
//    }
//    @RequestMapping("moban")
//    public Object moban(){
//        return "moban";
//    }
}
